/**
 * @description ordermodel
 */

const mongoose = require("../db/index");

const OrderSchema = mongoose.Schema(
  {
    username: {
      type: String,
      required: true,
    },
    shopName: String,
    ShopId: String,
    isCanceled: {
      type: Boolean,
      default: false,
    },
    address: {
      username: String,
      city: {
        type: String,
        required: true,
      },
      department: {
        type: String,
        required: true,
      },
      houseNumber: {
        type: String,
        required: true,
      },
      name: String,
      phone: String,
    },
    products: [
      {
        product: {
          shopId: {
            type: String,
          },
          name: {
            type: String,
            reuired: true,
          },
          imgUrl: String,
          sales: Number,
          price: Number,
          oldPrice: Number,
          tabs: [String],
        },
        orderSales: Number,
      },
    ],
  },
  { timestamps: true }
);

const OrderModel = mongoose.model("order", OrderSchema);

module.exports = OrderModel;
